package org.tobuy.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.tobuy.vo.Item;
import org.tobuy.factory.*;

public class ShowItems extends HttpServlet {

	
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String path = "index.jsp";
		List<Item> items = new ArrayList<Item>();
		try {
			items = ItemDAOFactory.getIItemDAOInstance().findItems();
		} catch (Exception e) {
			e.printStackTrace();
		}
		req.setAttribute("items", items);
		req.getRequestDispatcher(path).forward(req, resp);
				
	}


	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doGet(req, resp);
	}

}
